﻿using System.ComponentModel;
using System.Runtime.CompilerServices;
using Wix.Win8SetupBootstrapper.Annotations;

namespace Wix.Win8SetupBootstrapper.ViewModels
{
    public sealed class FeatureItemViewModel : INotifyPropertyChanged
    {
        internal string FeatureId { get; private set; }

        private bool _isSelected;

        public FeatureItemViewModel(string featureId, string caption, string variable)
        {
            this.Caption = caption;
            this.Variable = variable;
            FeatureId = featureId;
        }

        public FeatureItemViewModel(string featureId, string caption, string description, string size)
        {
            this.Caption = caption;
            Description = description;
            Size = size;
            FeatureId = featureId;
        }

        public string Caption { get; private set; }
        public string Description { get; set; }
        public string Size { get; set; }

        public string Variable { get; private set; }

        public string DescriptionWithSize
        {
            get { return string.Format("Descrption: {0}  Size:{1}", Description, Size); }
        }

        public bool IsSelected
        {
            get { return _isSelected; }
            set
            {
                _isSelected = value;
                OnPropertyChanged();
            }
        }


        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        private void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}